{{define "/chapter1/oneajax.html"}}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/static/js/jquery.min.js"></script>
</head>

<body>
    <form>
        文件: <input type="file" id="file"><br>
        姓名: <input type="text" id="name"><br>
        <input type="button" value="提交" id="add_btn"><br>
    </form>

    <script>
        var btn = document.getElementById("add_btn")
        btn.onclick = function () {
            var form_data = new FormData();
            var usrname = document.getElementById("name").value;
            // console.log($("#file")[0].files[0])
            form_data.append("file", $("#file")[0].files[0]);
            form_data.append("name", usrname);
            // alert(usrname);
            // alert(passwd);
            $.ajax({
                url: "/chapter1/getone",
                type: "POST",
                data: form_data,
                contentType:false,
                processData:false,
                success: function (data) {
                    alert(data["file"]);
                    alert(data["name"])
                },

                fail: function (data) {

                },
            })
        }
    </script>
</body>

</html>
{{end}}